
package com.joysuch.wwyt.bp.enums;

public enum RiskPointTypes {

    DEVICE_FACILITY("device", "设备设施"), JOB_ACTIVITY("job", "作业活动");

    private String code;
    private String name;

    private RiskPointTypes(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public boolean is(String code) {
        return code != null && this.code.equals(code);
    }

    public static RiskPointTypes findByName(String name) {
        RiskPointTypes[] values = RiskPointTypes.values();
        for (RiskPointTypes v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static RiskPointTypes findByCode(String code) {
        RiskPointTypes[] values = RiskPointTypes.values();
        for (RiskPointTypes v : values) {
            if (v.getCode().equals(code)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        RiskPointTypes types = findByCode(code);
        return types == null ? null : types.name;
    }
}
